﻿using yiCommerce.Core.Domain.Payments;
using yiCommerce.Service.Orders;

namespace yiCommerce.Service.Payments
{
    public class DummyPaymentMethod:IPaymentMethod
    {
        private IOrderService _orderService;
        private IOrderProcessingService _orderProcessingService;

        public DummyPaymentMethod(IOrderService orderService, IOrderProcessingService orderProcessingService)
        {
            _orderService = orderService;
            _orderProcessingService = orderProcessingService;
        }

        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
              var orders = _orderService.GetOrdersByTradeId(postProcessPaymentRequest.Trading.Id);
                        if (orders != null )
                        {
                            foreach (var order in orders)
                            {
                                _orderProcessingService.MarkOrderAsPaid(order.Id);
                            }
                        }
        }

        public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
             var result = new ProcessPaymentResult();
            result.NewPaymentStatus = PaymentStatus.Pending;
            return result;
        }

        public string SystemName { get { return "Dummy"; } }
        public bool CanRePostProcessPayment()
        {
            return  true;
        }
    }
}